home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 247
/
247.d81
/
e.fave zps
< prev
next >
Wrap
Text File
|
2022-08-26
|
6KB
|
213 lines
u PRINT THIS
FAMOUS ZERO-PAGE BYTES
----------------------
by Fender Tucker
The first 256 memory locations
used by your C64 are very important
to BASIC programs but there are only
a couple of dozen of them that you
really need to know about. These are
the locations I use most often.
I'm taking a lot of this
information from my second-most-
important C64 book, "Mapping the C64"
by Sheldon Leemon, Compute!
Publications, Inc. The most
important is, of course, the
"Programmer's Reference Guide" by
Commodore Business Machines, Inc.
ZERO PAGE - Locations 0 through 255
0 and 1 - Very important for I/O and
switching the ROMs in and out. Bits
0, 1 and 2 of location 1 are the
operative switches. Here's what
these bits do:
Bit
0 On BASIC ROM at $A000 (40960)
Off RAM at $A000
1 On Kernal ROM at $E000 (57344)
Off RAM at $E000
2 On I/O at $D000 (53248)
Off Character ROM at $D000
2 - Unused by BASIC. This is a
favorite place to store a value
between 0 and 255. Be careful
though, it's used by a lot of ML
routines.
19 - Default value is 0. If you POKE
a 64 here, the ? is suppressed from
an INPUT statement. Be sure to POKE
a 0 back in after you get your input
or you'll have cursor problems with
the BASIC screen editor. Since
LOADSTAR is not a fan of the INPUT
statement anyway, my advice is to
use this for your own programs, if
you want, but not for programs to be
used by the general public.
43 and 44 - Pointers to the start of
BASIC text. Default is 01 and 08 or
2049 decimal. To move the start of
BASIC text up to $1001 (4097) you
need to POKE 44,10:POKE 4096,0 in a
boot program. This allows enough
room for a font to be LOADed at
$0800. These locations are also
temporarily changed when appending
BASIC programs. If you ever get a
"syntax error" when entering a
simple BASIC command like RUN, you
probably need to POKE2048,0. If
you've moved BASIC up, then POKE a 0
into the value returned by
PEEK(44)*256.
45 and 46 - Start of Variables (SOV)
or, in another sense, end of
program. These bytes change as you
modify your program. Used in
appending also.
51 and 52, 55 and 56 - Usually only
the hi-bytes (52 and 56) need to be
changed to lower the top of BASIC.
The default value for 52 and 56 is
160 which places the top of BASIC
area at $A000 (40960).
160x256=40960. To free up room for
data, ML routines or whatever, poke
52 and 56 with a lower number.
197 and 203 - In "Mapping the C64"
there is a table of the values found
in these locations depending on
which key has been pressed. They are
the same for both locations except
that 197 shows the LAST key pressed,
while 203 shows the CURRENT key
pressed. These locations are handy
for checking for a keypress.
In the immediate mode enter this
command,
FORI=0TO9000:?PEEK(197);:NEXT
and press RETURN. A bunch of 64's
will be printed on the screen.
Then press any key and see what
number is printed. For instance, if
you press the SPACE bar the number
60 will be printed. Therefore
10 IF PEEK (197) = 60 THEN....
is the same as
10 GET A$: IF A$ = " " THEN....
If no key is pressed, both 197 and
203 will contain a 64.
This checks only for which key is
pressed. The SHIFT, CONTROL and LOGO
keys are not part of the keyboard
matrix so SHIFT-SPACE will give the
same value as unSHIFTed-SPACE.
198 - Number of characters in the
keyboard buffer queue. Default is 0.
To make sure that a previous
keypress is not lurking in the
buffer it's good programming
practice to POKE 198,0 before any
GET statement. Even more useful is
to POKE some BASIC tokens into the
keyboard buffer at 631 and then POKE
the number of tokens into 198. When
the program ends the commands you
POKEd will be executed even though
the program is over and no keys are
pressed! This is known as the
dynamic keyboard technique and is
handy for causing one program to
LOAD and RUN another. Just about all
of our boot programs use this
method. Check 'em out.
199 - A quick way to tell if you are
in the reversed mode. 0 = no. 1 =
yes. You can POKE or PEEK this
location from within your program.
212 - An easy way to get out of the
quote mode from within a program. 0
= no. If you want to PRINT a quote
mark on the screen but don't want
the user to be in the quote mode,
just POKE 212,0 afterwards.
214 - The best way (in my opinion) to
position your cursor in a program is
to POKE the row you want the cursor
on (minus 2) into 214. For
instance, POKE 214,12:PRINT will
position the cursor on the 14th row.
Use TAB or SPC to set the cursor Y
position.
217 through 242 - Screen line link
table. These are twenty-five bytes
(corresponding to the 25 screen
rows) that need to be manipulated
whenever you PRINT something in the
far right column. You'll notice that
you are having a heck of a time
getting succeeding text to print on
the correct line. If you have this
problem, do this:
200 FOR I = 217 TO 242: POKE I,
PEEK(I) OR 128:NEXT
and the screen will format
correctly. Technically, you only
need to do this for the offending
line but it's quick enough to fix
all the links at once in a FOR-NEXT
loop.
251 through 254 - These are favorite
free zero-page bytes for ML
programmers. Some of the addressing
modes require that addresses be in
zero page and since addresses are
two bytes long, having four in a row
is indeed handy.
By studying Sheldon Leemon's book
you'll find many more interesting
locations to play around with.
These are the ones I have used most
often in my programs.
FT